<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script type="text/javascript" >    

$(document).ready(function(){
	$("#create_event").click(function(){
		if($("#event_name").val() ==""){
			alert('event is empty');
		}
		else if($("#event_type").val() =="-1"){
			alert('please choose the event type');
		}
		else if($("#details_name").val() ==""){
			alert('details is empty');
		}
		else if($("#place_name").val() ==""){
			alert('place is empty');
		}
		else if($("#start_date").val() ==""){
			alert('start date is empty');
		}
		else if($("#end_date").val() ==""){
			alert('end date is empty');
		}
		else
		{	
			$("#event_form").submit();
		}
	});
});

</script>
</head>
<body>
<h1 align="center">Create a new event</h1>
	<form action="" method="post" id="event_form">
    <table align="center">
    	<tr>
        	<td>event name:</td>
            <td><input type="text" name="event_name" value="" id="event_name">
            <?php echo form_error('event_name');?></td>
        </tr>
        <tr>
        	<td>event type:</td>
            <td><select name="event_type" id="event_type">
            	<option value="-1">--select event type--</option>
                <option value="1">Birthday</option>
            </select>
            <?php echo form_error('event_type');?></td>
        </tr>
        <tr>
        	<td>deatails:</td>
            <td><textarea name="details" cols="20" rows="4" id="details_name"></textarea>
            <?php echo form_error('details');?></td>
        </tr>        
        <tr>
        	<td>place</td>
            <td><input type="text" name="place" value="" id="place_name"/>
            <?php echo form_error('place');?></td>
        </tr>        
        <tr>
        	<td>start date</td>
            <td><input type="text" name="start_date" value="" id="start_date"/>
            <?php echo form_error('date');?></td>
        </tr> 
         <tr>
        	<td>end date</td>
            <td><input type="text" name="end_date" value="" id="end_date"/>
            <?php echo form_error('date');?></td>
        </tr>        
        <tr>
        	<td>time</td>
            <td><input type="text" name="time" value=""/>
            <?php echo form_error('time');?></td>
        </tr>        
        <tr>
        	<td colspan="2" align="right"><button type="button" id="create_event">submit</button></td>
        </tr>        
     </table>
    </form>
    <?php if($this->session->userdata('event_sucess_message')){ echo "<h1 align='center'>".$this->session->userdata('event_sucess_message')."</h1>"; $this->session->unset_userdata('event_sucess_message'); } ?>

</body>

</html>